import Vue from 'vue'
import App from './App.vue'

import * as echarts from 'echarts'
import store from './store'
// 引入路由
import VueRouter from 'vue-router'
// 引入路由文件
import router from './router/index'
// element-ui所有组件
import ElementUI from 'element-ui'
// 引入element-ui组件库的所有样式
import 'element-ui/lib/theme-chalk/index.css'
import axios from './axios/axios'

import VueLazyload from 'vue-lazyload'
Vue.config.devtools = true
Vue.prototype.$axios = axios
Vue.prototype.$echarts = echarts
// 使用ElementUI
Vue.use(ElementUI)
Vue.use(VueRouter)

Vue.config.productionTip = false

axios.interceptors.request.use(
  config => {
    config.headers.token = store.state.token
    return config
  },
  err => {
    return Promise.reject(err)
  }
)
Vue.use(VueLazyload)
Vue.use(VueLazyload, {
  preLoad: 1.3,
  error: './assets/img/errorImg.png',
  loading: './assets/img/errorImg.png',
  attempt: 1
})
new Vue({
  router,
  store,
  // beforeCreate () {
  //   Vue.prototype.$bus = this // 安装全局事件总线
  // },
  render: h => h(App)
}).$mount('#app')
